# Schema as of June 12, 2006 15:45 (schema version 7)
#
# Table name: orders
#
#  id       :integer(11)   not null, primary key
#  nome     :string(255)
#  endereco  :text
#  email    :string(255) 

class Pedido < ActiveRecord::Base

  has_many :line_items
  
  #START:validate
  validates_presence_of :name, :address, :email
  #validates_inclusion_of :pay_type, :in => PAYMENT_TYPES.map {|disp, value| value}
  #END:validate

  #START:add_line_items_from_cart
  def add_line_items_from_cart(cart)
    cart.items.each do |item|
      li = LineItem.from_cart_item(item)
      line_items << li
    end
  end
  #END:add_line_items_from_cart
end
